package com.yoda.controller;


import com.yoda.dto.AdvDto;
import com.yoda.dto.AdvPageQuery;
import com.yoda.entity.YddAdvpos;
import com.yoda.result.Result;
import com.yoda.service.IYddAdvposService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/ydd_advpos")
@Slf4j
public class YddAdvposController {
    @Autowired
    private IYddAdvposService service;

    /**
     * 分页查询
     * @return
     */
    @GetMapping("/list")
    public Result pageQuery(AdvPageQuery advPageQuery){
        return service.pageQuery(advPageQuery);
    }

    /**
     * 广告位修改
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public Result updateAdv(@RequestBody AdvDto dto){
        return service.updateAdv(dto);
    }

    /**
     * 广告位详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result selectById(String id){
        return service.selectById(id);
    }

    /**
     * 广告位删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result deleteById(String id){
        return service.deleteById(id);
    }

    /**
     * 广告位列表-全部
     * @return
     */
    @GetMapping("/all")
    public Result selectAll(){
        log.info("查询所有");
        return service.selectAll();
    }

    /**
     *  广告位添加
     * @param yddAdvpos
     * @return
     */
    @PostMapping("/add")
    public Result addAdv(@RequestBody YddAdvpos yddAdvpos){
        return service.addAdv(yddAdvpos);
    }
}

